package cn.kjcoder.springcloud.controller;

import cn.kjcoder.springcloud.service.IPaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hkj
 * @email 1349091387@qq.com
 * @date 2021/12/24
 * 源码允许修改，并且本人十分乐意有 大佬 来对代码进行 随 意 调 教
 **/
@RestController
@Slf4j
@RequestMapping("payment")
public class PaymentController {

    @Value("${server.port}")
    private String port;
    @Autowired
    private IPaymentService paymentService;


    @GetMapping("/hystrix/ok/{id}")
    public String payment_OK(@PathVariable("id")Integer id){
        String result = paymentService.payment_OK(id);
        log.info("**********reuslt : " + result);
        return result;
    }

    @GetMapping("/hystrix/timeout/{id}")
    public String payment_Timeout(@PathVariable("id")Integer id){
        String result = paymentService.payment_Timeout(id);
        log.info("**********reuslt : " + result);
        return result;
    }

    /*****************************************服务熔断***************************************************/
    @GetMapping("/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id){
        String result = paymentService.paymentCircuitBreaker(id);
        log.info("*******result:"+result);
        return result;
    }


}
